﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebMatrix.WebData;
using System.Web.Security;



namespace lnxsj.web.Recruitment.Areas.manage.Controllers
{
    using Models;
    using Filters;
    [Authorize]
    [InitializeSimpleMembership]
    public class homeController : Controller
    {
        //
        // GET: /manage/home/
        
        public ActionResult Index()
        {
            return View();
        }
        [HttpGet]
        [AllowAnonymous]
        public ActionResult Login()
        {
            var db = new RecrunitmenutDB();
            if (db.Users.Count() == 0)
            {

                return Redirect("/manage/user/CreateDefault");
            }

            return View();

        }

        public ActionResult unLogin()
        {
            WebSecurity.Logout();
            return Redirect("/manage/");

        }
        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult Login(LoginModel model)
        {


            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                
                return RedirectToAction("index") ;
            }


            // 如果我们进行到这一步时某个地方出错，则重新显示表单
            ModelState.AddModelError("", "提供的用户名或密码不正确。");
            return View(model);

        }

        public ActionResult ChangePassword() {
            return View();
        }
        [HttpPost]
        public ActionResult ChangePassword(ChangePasswordModel model) {
            return View();
        
        }


    }
}
